<?php
/*
 * Rpc接口基础类
 */
class RpcQuote{
	static function login($username,$password)
	{
		$identity = new UserIdentity($username, $password);
		$ret = $identity->authenticate(false,true);
		if ($ret['msgcode']===0){
			if (!isset($_SESSION['authcode']))
				$_SESSION['authcode']=session_id();
			$ret['authcode'] = $_SESSION['authcode'];
		}
		return $ret;
	}
	
	static function auth($authcode)
	{
		if (!isset($_SESSION['authcode']) || $authcode==='' || $authcode===null)
			return 'U r not logined.';
		elseif ($_SESSION['authcode'] === $authcode)
			return 'U r logined.';
		else
			return 'U r expired.';
	}
	
	static function getUsers() {
		return User::model()->findAll();
	}
	
	static function hello($name) {
		return 'hello'.$name;
	}
	
	function paramObject($param){
		$obj = new ParamObject();
		$map = array();
		if(empty($param)){
			$obj->stringVar = "ParamObject was empty";
			$map["Message"] = "No Message";
		} else {
			$obj->stringVar = "ParamObject not empty";
			$map["Message"] = $param->stringVar;
		}
		$obj->hashVar = $map;
		return $obj;
	}
}